package cn.tedu.redirect;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
//测试---响应
@WebServlet("/order/ServletA")
public class ServletA extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //重定向和请求转发的区别？？？
        //1.请求转发是请求request的功能，全程1次请求1次响应，地址栏不变
//        request.getRequestDispatcher("目标访问的方式").forward(请求，响应);
        //2.重定向是response的功能，全程2次请求2次响应，地址栏改变
        System.out.println("ServletA被访问");
        response.sendRedirect("https://www.baidu.com/");
    }
}
